#include "PizzaRecipe.hpp"
#include "Options/Options.hpp"
#include "Pizza.hpp"

namespace pizzeria {

PizzaRecipe::PizzaRecipe(PizzaType pizzaType) {
  BasicRecipe();
  switch (pizzaType) {
  case Pizza::Regina:
    UseRecipeRegina();
    break;
  case Pizza::Fantasia:
    UseRecipeFantasia();
    break;
  case Pizza::Margarita:
    UseRecipeMargarita();
    break;
  case Pizza::Americaine:
    UseRecipeAmericaine();
    break;
  }
}

PizzaRecipe::PizzaRecipe(const PizzaRecipe& toCopy) {
  mCookingTime = toCopy.mCookingTime;
  mIngredients = toCopy.mIngredients;
}

PizzaRecipe::~PizzaRecipe() {

}

PizzaRecipe& PizzaRecipe::operator =(const PizzaRecipe& toCopy) {
  if (this != &toCopy) {
    mCookingTime = toCopy.mCookingTime;
    mIngredients = toCopy.mIngredients;
  }
  return *this;
}

void PizzaRecipe::BasicRecipe() {
  mCookingTime = Options::GetInstance().GetCookingTime();
  mIngredients[DOE] = true;
  mIngredients[TOMATO] = true;
  mIngredients[GRUYERE] = false;
  mIngredients[HAM] = false;
  mIngredients[MUSHROOM] = false;
  mIngredients[STEAK] = false;
  mIngredients[EGGPLANT] = false;
  mIngredients[GOAT_CHEESE] = false;
  mIngredients[CHIEF_LOVE] = false;
}

void PizzaRecipe::UseRecipeMargarita() {
  mIngredients[DOE] = true;
  mIngredients[TOMATO] = true;
  mIngredients[GRUYERE] = true;
  mCookingTime *= 1;
}

void PizzaRecipe::UseRecipeRegina() {
  mIngredients[DOE] = true;
  mIngredients[TOMATO] = true;
  mIngredients[GRUYERE] = true;
  mIngredients[HAM] = true;
  mIngredients[MUSHROOM] = true;
  mCookingTime *= 2;
}

void PizzaRecipe::UseRecipeAmericaine() {
  mIngredients[DOE] = true;
  mIngredients[TOMATO] = true;
  mIngredients[GRUYERE] = true;
  mIngredients[STEAK] = true;
  mCookingTime *= 2;
}

void PizzaRecipe::UseRecipeFantasia() {
  mIngredients[DOE] = true;
  mIngredients[TOMATO] = true;
  mIngredients[EGGPLANT] = true;
  mIngredients[GOAT_CHEESE] = true;
  mIngredients[CHIEF_LOVE] = true;
  mCookingTime *= 4;
}

const std::map<PizzaIngredients, bool>& PizzaRecipe::GetIngredients() {
  return mIngredients;
}

bool PizzaRecipe::IsDoeNeeded() const {
  return mIngredients.at(DOE);
}

bool PizzaRecipe::IsEggplantNeeded() const {
  return mIngredients.at(EGGPLANT);
}

bool PizzaRecipe::IsGoatCheeseNeeded() const {
  return mIngredients.at(GOAT_CHEESE);
}

bool PizzaRecipe::IsGruyereNeeded() const {
  return mIngredients.at(GRUYERE);
}

bool PizzaRecipe::IsHamNeeded() const {
  return mIngredients.at(HAM);
}

bool PizzaRecipe::IsMushroomNeeded() const {
  return mIngredients.at(MUSHROOM);
}

bool PizzaRecipe::IsSteakNeeded() const {
  return mIngredients.at(STEAK);
}

bool PizzaRecipe::IsTomatoNeeded() const {
  return mIngredients.at(TOMATO);
}

bool PizzaRecipe::IsChiefLoveNeeded() const {
  return mIngredients.at(CHIEF_LOVE);
}

unsigned int PizzaRecipe::GetCookingTime() const {
  return mCookingTime * 1000000;
}

} /* !namespace pizzeria */
